package com.charging.controller.user;


import com.charging.entity.ChargingPile;
import com.charging.service.ChargingPileService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/user/pile")
public class PileController {

    @Resource
    private ChargingPileService chargingPileService;

    @GetMapping("/list")
    public String list(Model model){
        List<ChargingPile> chargingPileList = chargingPileService.findAll();
        model.addAttribute("chargingPileList",chargingPileList);
        return "user/pile/list";
    }

    @GetMapping("/detail/{id}")
    public String detail(@PathVariable Long id, Model model) {

        ChargingPile chargingPile = chargingPileService.findById(id);
        model.addAttribute("chargingPile", chargingPile);
        return "user/pile/detail";
    }

}
